{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="tablesWrap">  
<!-- end tables-searchbox -->  
<table class="wxtables">  
    <colgroup>  
    <col width="5%">
    <col width="10%">
    <col width="10%">
    <col width="8%">
    <col width="12%">
    <col width="10%">
    <col width="15%">
    <col width="15%">
    <col width="15%">
    </colgroup>
    <thead>
        <tr>  
            <td>选择</td>  
            <td>预约号</td>  
            <td>预约手机</td>  
            <td>姓名</td>  
            <td>预约时间</td>  
            <td>预约状态</td>  
            <td>预约提交时间</td>  
            <td>预约使用时间</td>  
            <td>操作</td>
        </tr>  
    </thead>  
	{foreach from=$appoint_list item=appoint}
    <tbody class="combo-tbody">  
        <tr>  
			<td><input type="checkbox" class="checkbox" name="a[]" value="{$appoint.appoint_id}"></td>
            <td>{$appoint.appoint_number}</td>  
			<td>{$appoint.mobile}</td>  
			<td>{$appoint.realname}</td>  
			<td>{$appoint.appoint_time|date_format:"%Y-%m-%d"}</td>  
			<td>{$appoint.appoint_status}</td>  
			<td>{$appoint.addtime|date_format:"%Y-%m-%d %H:%M:%S"}</td>  
			<td>{if $appoint.use_time}{$appoint.use_time|date_format:"%Y-%m-%d %H:%M:%S"}{else}--{/if}</td> 
            <td>  
				<a href="javascript:;" class="btn" title="使用" onclick="use_appoint({$appoint.appoint_id})">使用</a>  
                <a href="javascript:;" class="btn" title="删除" onclick="delete_appoint({$appoint.appoint_id})">删除</a>  
            </td>  
        </tr>
    </tbody>
	{foreachelse}   
    <tbody>    
		<tr>
			<td colspan="7">
				没有符合条件的记录
			</td>
		<tr>
    </tbody>  
	{/foreach}
</table>  
<!-- end wxtables -->  
<div class="tables-btmctrl clearfix">  
    <div class="fl">  
        <a href="javascript:;" class="btn btn-blue" onclick="Select()">全选</a>  
        <a href="javascript:;" class="btn btn-blue" onclick="Cancel()">取消</a>  
        <a href="javascript:;" onclick="batch_delete()" class="btn btn-blue">删除</a>
    </div>  
    <div class="fr">  
        <div class="paginate">
			{$show} 
        </div>  
        <!-- end paginate -->  
    </div>  
</div>  
<!-- end tables-btmctrl -->  
</div>  
<!-- end tablesWrap -->   
{/block} 

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
{literal}
<script>
	//全选
	function Select(){
		var sel=document.getElementsByName("a[]");
		for(var i=0;i<sel.length;i++){
			sel[i].checked=true;
		}
	}
	//取消全选
	function Cancel(){
		var sel=document.getElementsByName("a[]");
		for(var i=0;i<sel.length;i++){
			sel[i].checked=false;
		}
	}

function delete_appoint(appoint_id)
{
	$.jPops.confirm(
	{  
		 title:"提示",  
		 content:"您确定要删除这条数据吗？",  
		 okBtnTxt:"确定",  
		 cancelBtnTxt:"取消",  
		 callback:function(r)
		 {  
			 if(r)
			 {
				 $.post('/AcpAppoint/delete_appoint', {"appoint_id":appoint_id}, function(data, textStatus) 
				 {
					if (data == 'success')
					{
						alert('恭喜您，删除成功！');
						location.reload();
					}
					else
					{
						alert('对不起，删除失败！');
					}
				});
			 }  
			 return true;  
		 }
	 });  	
}

function batch_delete()
{
	$.jPops.confirm(
	{  
		 title:"提示",  
		 content:"您确定要删除这些数据吗？",  
		 okBtnTxt:"确定",  
		 cancelBtnTxt:"取消",  
		 callback:function(r)
		 {  
			 if(r)
			 {
				 var appoint_ids = '';
				 var count = 0;
				 $('input[name="a[]"]:checked').each(function(){
					 count ++;
					 appoint_ids += $(this).val() + ',';
				 });

				 if (!count)
				 {
					 alert('对不起，请选择至少一项进行删除！');
					 return;
				 }

				 appoint_ids = appoint_ids.substr(0, appoint_ids.length - 1);

				 $.post('/AcpAppoint/batch_delete_appoint', {"appoint_ids":appoint_ids}, function(data, textStatus) 
				 {
					if (data == 'success')
					{
						alert('恭喜您，删除成功！');
						location.reload();
					}
					else
					{
						alert('对不起，删除失败！');
					}
				});
			 }  
			 return true;  
		 }
	 });
}

function use_appoint(appoint_id)
{
	$.post('/AcpAppoint/use_appoint', {'appoint_id':appoint_id}, function(data){
		if (data != 'failure')
		{
			alert('恭喜您，预约号使用成功！');
			location.href = '/AcpAppoint/appoint_query';
		}
		else
		{
			alert('抱歉，该预约号已使用！');
		}
	});
}
</script>
{/literal}
{/block} 

{block name="css"}
<link type="text/css" rel="stylesheet" href="__ACPCSS__/tip.css" />
{literal}
<style>
.PageNext{page-break-after: always; height:1px;}
</style>
{/literal}
{/block} 
